require(['jquery', 'cookie', 'app', 'lay'], function ($) {
    layui.use(['form', 'laydate', 'upload'], function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#createTime', //指定元素

        });
        laydate.render({
            elem: '#endTime', //指定元素

        });
    });
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: [],
                that: {

                }
            }
            , created: function () {
                this.seachs();
            }
            , methods: {
                loadPage: function () {
                    var re =[
                        {
                            "field":"",
                            "title":"序号",
                            "type":"numbers",
                            totalRowText: '合计'
                        },
                        {
                            "field":"2",
                            "title":"商品名称"
                        },
                        {
                            "field":"3",
                            "title":"规格名称"
                        },
                        {
                            "field":"0",
                            "title":"数量"
                            ,totalRow: true
                        },
                        {
                            "field":"1",
                            "title":"总收入",
                            totalRow: true
                        },
                        {
                            "field":"4",
                            "title":"单价"
                        },
                        {
                            "field":"5",
                            "title":"成本"
                        },
                        {
                            "field":"6",
                            "title":"利润",
                            totalRow: true
                        }
                    ];
                    var toolbar = [];
                    bspNO($(".sa-table"), "TJController/Shop", re, this.where, toolbar);
                },
                seachs: function () {
                    this.where = whereJSON($(".el-form"));
                    this.loadPage();
                },
                referXadmin: function () {
                    window.location.reload();
                },
                xzYWY:function (e) {
                    e = e.currentTarget;
                    layui.use('layer', function () {
                        layer.open({
                            type: 2
                            , content: "./51?type=BUSINESS"
                            , area: ["800px", "400px"]
                            , btn: ['确定', '取消']
                            , yes: function (index, layero) {
                                var body = layer.getChildFrame('body', index);
                                var w = $(layero).find("iframe")[0].contentWindow;
                                var jon = w.checkSure();
                                $(e).val(jon['uuid']);
                                $(e).attr("uuid", jon['uuid']);
                                layer.closeAll();
                            }
                            , btn2: function (index, layero) {
                                layer.closeAll();
                            }
                            , cancel: function () {
                                layer.closeAll();
                            }
                        });
                    });
                }
            }
        });
    })
});
function update(uuid) {
    window.parent.sp.showTab({id: getCode(2), name: '修改优惠券', url: './vsp/49?uuid='+uuid})
}
function deleted(uuid) {
    var re = playAjax("/SaleController/Del",{uuid:uuid});
    alr(re.msg);
    if(re.code==200){
        setTimeout(function () {
            window.reload();
        },500);
    }
}
